package com.atguigu.controller;

import com.atguigu.pojo.User;
import com.atguigu.service.UserService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/user/")
public class UserController {

    @Autowired
    private UserService userService;


    @GetMapping("/getUserPageList")
    public PageInfo<User> getUserPageList(int pageNum,int pageSize){
        return userService.getUserPageList(pageNum,pageSize);
    }

    @PostMapping("/insertUser")
    public void insertUser(@RequestBody User user){
       userService.insertUser(user);
    }

    @PutMapping("/updateUser")
    public void updateUser(@RequestBody User user){
        userService.updateUser(user);
    }
    @DeleteMapping("/deleteUserById")
    public void deleteUserById(int id){
        userService.deleteUserById(id);
    }

    @GetMapping("/findUserById/{id}")
    public User findUserById(@PathVariable int id){
       return userService.findUserById(id);
    }

}
